#include <iostream>
#include <thread>

#include "CanDriver.h"

int main() {
    canpp::loggingConfigure({true, true, true, true, true, true});
    const auto driver = std::make_unique<canpp::CanDriver<>>
    (std::move(canpp::CanDriverConfig{
        "can0", "driver1"
    }));

    driver->registerReadingCallback(std::move([](const can_frame &frame) { std::cout << frame.can_id << "\n"; }));

    std::this_thread::sleep_for(std::chrono::seconds(5));

    can_frame frame = {0x130, {8}};
    std::array<uint8_t, 8> array{1, 2, 3, 4, 5, 6, 7, 8};
    std::ranges::move(array, frame.data);

    driver->canSendMessage(can_frame(frame));
    std::this_thread::sleep_for(std::chrono::seconds(1));
    driver->canSendMessage(can_frame(frame));
    std::this_thread::sleep_for(std::chrono::seconds(1));
    driver->canSendMessage(can_frame(frame));
    std::this_thread::sleep_for(std::chrono::seconds(1));
    driver->canSendMessage(can_frame(frame));
    std::this_thread::sleep_for(std::chrono::seconds(1));

    return EXIT_SUCCESS;
}
